package com.matt.order.service;

import com.matt.order.dto.CustomerDto;
import com.matt.order.repository.CustomerEnterMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustomerEnterService {
    @Autowired
    CustomerEnterMapper customerEnterMapper;

    public int customerInfoInsert(CustomerDto customerEnterDto) {
        int customerCount = customerEnterMapper.getCountByCustomerName(customerEnterDto);
        if (customerCount > 0) {
            return 1;
        } else {
            customerEnterMapper.customerInfoInsert(customerEnterDto);
            return 0;
        }
    }

    public List<CustomerDto> customerInfoList() {
        return customerEnterMapper.customerInfoList();
    }

    public List<CustomerDto> customerGenderSUMInfoList() {
        return customerEnterMapper.customerGenderSUMInfoList();
    }

    public List<CustomerDto> customerSourceSUMInfoList() {
        return customerEnterMapper.customerSourceSUMInfoList();
    }

    public String customerPaySumInfo() {
        return customerEnterMapper.customerPaySumInfo();
    }
}
